package com.hb.trade.api.push.manger;

import cn.hutool.json.JSONObject;
import com.hb.core.pojo.project.push.dto.PushDockingLogDTO;
import com.hb.core.pojo.project.push.entity.PushDockingLog;
import com.hb.trade.api.push.util.PushTypeEnum;

/**
 * describe:
 *
 * @author zhongdl
 * @date 2022/02/22
 */
public class PushDockingLogManger extends PushDockingLogDTO {



    public static PushDockingLog generatePushDockingLog(PushTypeEnum pushTypeEnum, Long businessId, JSONObject jsonObject){
        //成功还是失败
        Boolean serviceFlag = jsonObject.getBool("SERVICE_FLAG");
        //回执信息
        String serviceMessage = jsonObject.getStr("SERVICE_MESSAGE");

        PushDockingLog pushDockingLog = new PushDockingLog();
        pushDockingLog.setBusinessId(businessId);
        pushDockingLog.setType(pushTypeEnum.getCode());
        pushDockingLog.setStatus(serviceFlag ? 1 : -1);
        pushDockingLog.setOtherKeyWord(pushTypeEnum.getName());
        pushDockingLog.setServiceMessage(serviceMessage);
        return pushDockingLog;
    }
}
